//-------------------------------------------------------------------
//	Copyright (c) 2010-2014  Zhirnov Andrey
//	This file is part of the "UX Standard Lib" project.
//	See copyright notice in "UX_STL_Ext.h".
//-------------------------------------------------------------------

#ifndef _UXS_SDL_PLATFORM_H
#define _UXS_SDL_PLATFORM_H

#pragma once

#include "../Base/OSTypes.h"

#ifdef PLATFORM_SDL

#include "SdlKeyCodes.h"

namespace UX_STL
{
namespace _platform_
{
	using namespace UXTypes;
	using namespace UXMath;

	#define NEWLINE			"\n"

	

	//
	// SDL Platform (static functions only)
	//

	struct UX_EXPORT SDLPlatform
	{
		static uvec2 ScreenResolution();
		static uvec2 ScreenPhysicalSize();
		/*
		static void  GetInstance (THandles &sHandles);
		static bool  GetModulePath (string &sPath, uni_c_string pModuleName);
		static bool  GetModulePath (string &sPath, void *pModule = null);
		static bool  GetSystemPath (string &sPath);

		static void* AllocPage (usize uPageSize);
		static bool  FreePage (void *pPage);
		
		static bool  GetDate (Date &sDate);
		static bool  GetDate (string &str, e_date::type eType);

		static bool  GetSystemInfo (TSystemInfo &sInfo);
		static void  GetSystemInfoString (const TSystemInfo &sInfo, string &sStr);
	
		static bool  SetTimer (const THandles &sHandles, uint32 &uTimer, uint uElapse);
		static bool  KillTimer (const THandles &sHandles, uint32 uTimer);
		
		static bool  ShowCursor (bool bShow);
		static bool  SetCursorPos (const ivec2 &vPos);
		*/
		static void  GetMemory (uint &uTotal, uint &uFree);
		static void  GetVirtualMemory (uint &uTotal, uint &uFree);

		static void  Yield ();
		static void  Delay (uint timeMSec);
		/*
		static bool  GetScreenModes (array<TScreenMode> &aModes);
		static bool  ChangeScreenResolution (const uvec2 &sScrRes, const uint8 uColors = 8, uint uFreq = 0);

		static e_msg_button_ret::type ErrorMsg (uni_c_string pCaption, uni_c_string pText, e_msg_buttons::type eButtons);*/
	};

	
	inline uvec2 SDLPlatform::ScreenResolution()
	{
		::SDL_DisplayMode mode = {0};
		::SDL_GetCurrentDisplayMode( 0, &mode );
		return uvec2( mode.w, mode.h );
	}

	inline uvec2 SDLPlatform::ScreenPhysicalSize()
	{
		TODO("");
		return uvec2(0);
	}

	inline void SDLPlatform::GetMemory (uint &uTotal, uint &uFree)
	{
		uTotal = 0;
		uFree  = 0;
	}

	inline void SDLPlatform::GetVirtualMemory (uint &uTotal, uint &uFree)
	{
		uTotal = 0;
		uFree  = 0;
	}

	inline void SDLPlatform::Yield ()
	{
		Delay(1);
	}

	inline void SDLPlatform::Delay (uint timeMSec)
	{
		::SDL_Delay( timeMSec );
	}


}	// _platform_
}	// UX_STL

#endif	// PLATFORM_SDL
#endif	// _UXS_SDL_PLATFORM_H